<?php
namespace app\agent\controller\system;
class Config extends \app\agent\controller\Common
{
    public function index(){
        if (request()->isPost()) {
            $data = request()->param();
            if(isset($data['not_business_hours_start']) && isset($data['not_business_hours_end'])){
                $data['not_business_hours'] = $data['not_business_hours_start']."-".$data['not_business_hours_end'];
            }
            if(empty($data['is_close'])){
                $data['is_close'] = 0;
            }
            (new \app\common\model\AgentConfig())->save($data,['agent_id' => $this->userInfo['id']]);
            return self::successResult();
        } else {
            $config = (new \app\common\model\AgentConfig())->where(['agent_id' => $this->userInfo['id']])->find();
            if(empty($config)){
                (new \app\common\model\AgentConfig())->save([
                    'tel' => wconfig('TEl'),
                    'agent_id' => $this->userInfo['id']
                ]);
            }
            $config = (new \app\common\model\AgentConfig())->where(['agent_id' => $this->userInfo['id']])->find();
            $this->assign("info",$config);
            return view();
        }
    }



  

  

 
}
